﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Stats.Objects;

namespace Stats
{
    class Tests
    {

        #region getUserFeedback Tests

        public static void testGetUserGeneralFeedback(int userID)
        {
            GeneralFeedback fdbG1 = StatsModule.getGeneralFeedback(userID);

            System.Console.WriteLine("---- USER GENERAL FEEDBACK ----");
            System.Console.WriteLine("GENERAL VOTE: " + fdbG1.Vote);
            System.Console.WriteLine("GENERAL PUNCTUALITY VOTE: " + fdbG1.Punctuality);
            System.Console.WriteLine("GENERAL RELIABILITY VOTE: " + fdbG1.Reliability);
            System.Console.WriteLine();
        }

        public static void testGetUserAsDriverFeedback(int userID)
        {
            AsDriverFeedback fdb = StatsModule.getAsDriverFeedback(userID);

            System.Console.WriteLine("---- USER AS DRIVER FEEDBACK ----");
            System.Console.WriteLine("AS DRIVER --> GENERAL VOTE = " + fdb.Vote);
            System.Console.WriteLine("AS DRIVER --> PUNCTUALITY VOTE = " + fdb.Punctuality);
            System.Console.WriteLine("AS DRIVER --> RELIABILITY VOTE = " + fdb.Reliability);
            System.Console.WriteLine("AS DRIVER --> KINDNESS VOTE = " + fdb.Courtesy);
            System.Console.WriteLine();
        }

        public static void testGetUserAsPassengerFeedback(int userID)
        {
            AsPassengerFeedback fdbP = StatsModule.getAsPassengerFeedback(userID);

            System.Console.WriteLine("---- USER AS PASSENGER FEEDBACK ----");
            System.Console.WriteLine("AS PASSENGER --> GENERAL VOTE = " + fdbP.Vote);
            System.Console.WriteLine("AS PASSENGER --> PUNCTUALITY VOTE = " + fdbP.Punctuality);
            System.Console.WriteLine("AS PASSENGER --> RELIABILITY VOTE = " + fdbP.Reliability);
            System.Console.WriteLine();
        }

        public static void testGetUserFeedbackList(int userID)
        {
            List<Feedback> feedbackList = StatsModule.getUserFeedbackList(userID);

            if (feedbackList == null) System.Console.WriteLine("NO FEEDBACKS LEFT FOR THAT USER");
            else
            {
                for (int i = 0; i < feedbackList.Count; i++)
                {
                    Feedback singleFeedback = feedbackList.ElementAt(i);

                    System.Console.WriteLine("FEEDBACK " + (i + 1) + " - LEFT FOR THE USER " + singleFeedback.receiverNickname);
                    System.Console.WriteLine("SENT BY USER " + singleFeedback.senderNickname + " FOR THE TRIP: " + singleFeedback.tripID);
                    System.Console.WriteLine("DEPARTURE DATE: " + singleFeedback.departureDate.ToShortDateString());
                    System.Console.WriteLine("TRIP FROM: " + singleFeedback.originCity + ", " + singleFeedback.originAddress);
                    System.Console.WriteLine("TRIP TO: "+ singleFeedback.destinationCity + ", " + singleFeedback.destinationAddress);
                    
                    if (singleFeedback.feedbackType) System.Console.WriteLine("TYPE: DRIVER");
                        else System.Console.WriteLine("TYPE: PASSENGER");

                    System.Console.WriteLine("GENERAL VOTE: " + singleFeedback.generalVote);
                    System.Console.WriteLine("PUNCTUALITY: " + singleFeedback.punctualityVote);
                    System.Console.WriteLine("RELIABILITY: " + singleFeedback.reliabilityVote);
                    if (singleFeedback.feedbackType) System.Console.WriteLine("COURTESY: " + singleFeedback.courtesyVote);
                    System.Console.WriteLine("COMMENT LEFT: " + singleFeedback.commentLeft);
                    System.Console.WriteLine();
                    System.Console.WriteLine("-------------------------------------------------------");
                    System.Console.WriteLine();
                }
            }

            
        }

        #endregion

        #region getGeneralStats Test

        // DEPRECATED
        //public static void testGetGeneralStats()
        //{
        //    GeneralStats gen = StatsModule.getGeneralStats();

        //    int nDays = gen.NumberDaysStatsReferred;

        //    System.Console.WriteLine("GENERAL STATS REPORT ABOUT LAST " + nDays + " DAYS");
        //    System.Console.WriteLine();

        //    System.Console.WriteLine("TOTAL KM DONE: " + gen.TotalKm);
        //    System.Console.WriteLine("AVG KM DONE PER DAY: " + (double)gen.TotalKm / nDays);
        //    System.Console.WriteLine("TOTAL FUEL SAVED: " + gen.TotalFuelSaved + " LITERS");
        //    System.Console.WriteLine("AVG FUEL PER DAY: " + (double)gen.TotalFuelSaved / nDays + " LITERS");
        //    System.Console.WriteLine("TOTAL MONEY SAVED: " + gen.TotalMoneySaved + " EURO");
        //    System.Console.WriteLine("AVG MONEY PER DAY: " + (double)gen.TotalMoneySaved / nDays + " EURO");
        //    System.Console.WriteLine("TOTAL POLLUTION SAVED: " + gen.TotalPollutionSaved);
        //    System.Console.WriteLine("AVG POLLUTION PER DAY: " + (double)gen.TotalPollutionSaved / nDays);
        //    System.Console.WriteLine();
        //    System.Console.WriteLine("TOTAL PASSENGERS CARRIED: " + gen.TotalPassengersCarried);
        //    System.Console.WriteLine("AVG PASSENGERS CARRIED PER DAY: " + (double)gen.TotalPassengersCarried / nDays);
        //    System.Console.WriteLine("TOTAL PASSENGERS CARRIED ON THE WAY: " + gen.PassengersCarriedOnWayNumber);
        //    System.Console.WriteLine("AVG PASSENGERS CARRIED ON THE WAY PER DAY: " + (double)gen.PassengersCarriedOnWayNumber / nDays);
        //    System.Console.WriteLine("TOTAL PROPOSED TRIPS: " + gen.ProposedTripsNumber);
        //    System.Console.WriteLine("AVG PROPOSED TRIPS PER DAY: " + (double)gen.ProposedTripsNumber / nDays);
        //    System.Console.WriteLine("TOTAL HANDSHAKED TRIPS: " + gen.HandshakedTripsNumber);
        //    System.Console.WriteLine("AVG HANDSHAKED TRIPS PER DAY: " + (double)gen.HandshakedTripsNumber / nDays);
        //    System.Console.WriteLine("TOTAL MISSED TRIPS: " + gen.MissedTripsNumber);
        //    System.Console.WriteLine("AVG MISSED TRIPS PER DAY: " + (double)gen.MissedTripsNumber / nDays);
        //    System.Console.WriteLine();
        //}

        #endregion

        #region getUserProfile Test

        public static void testGetUserProfile(int userID)
        {
            UserProfile usr = StatsModule.getUserProfile(userID);

            UserStats us = usr.UserStats;
            
            System.Console.WriteLine("USER "+userID+" TRIPS AS DRIVER: "+ us.AsDriverTripsNumber);
            System.Console.WriteLine("USER "+userID+" TRIPS AS PASSENGER: "+us.AsPassengerTripsNumber);
            System.Console.WriteLine("USER "+userID+" TOTAL PASSENGERS CARRIED: "+us.TotalPassengersCarried);
            System.Console.WriteLine("USER "+userID+" TOTAL PASSENGERS CARRIED ON THE WAY: "+us.TotalPassengersCarriedOnTheWay);
            System.Console.WriteLine("USER "+userID+" MAX PASSENGERS CARRIED: "+us.MaxPassengersCarried);
            System.Console.WriteLine("USER "+userID+" PROPOSED TRIP COUNT: "+us.ProposedTripsNumber);
            System.Console.WriteLine("USER "+userID+" HANDSHAKED TRIP COUNT: "+us.HandshakedTripsNumber);
            System.Console.WriteLine("USER "+userID+" MISSED APPOINTMENTS AS DRIVER COUNT: "+us.MissedAppointmentsAsDriver);
            System.Console.WriteLine("USER "+userID+" MISSED APPOINTMENTS AS PASSENGER COUNT: " + us.MissedAppointmentsAsPassenger);

            System.Console.WriteLine("USER "+userID+" TOTAL KM DONE: "+us.TotalKm);
            System.Console.WriteLine("USER "+userID+" TOTAL EMISSIONS SAVED: "+us.TotalPollutionSaved);
            System.Console.WriteLine("USER "+userID+" TOTAL FUEL SAVED: "+us.TotalFuelSaved);
            System.Console.WriteLine("USER "+userID+" TOTAL MONEY SAVED: "+us.TotalMoneySaved);
            
        }

        #endregion

        #region getUserPassengersCount & user trips stats Tests

        public static void testGetUserMaxPassengers(int userID)
        {
            System.Console.WriteLine("USER "+userID+ " ---> MAX PASSENGERS CARRIED IN A SINGLE TRIP: " + AuxUserMethods.getMaxPassengerCarriedInATrip(userID));
        }

        public static void testGetUserTotalPassengersCarried(int userID)
        {
            System.Console.WriteLine("USER " + userID + " ---> TOTAL PASSENGERS CARRIED: " + AuxUserMethods.getUserTotalCarriedPassengersCount(userID));
        }

        public static void testGetUserTotalPassengersCarriedOnTheWay(int userID)
        {
            System.Console.WriteLine("USER " + userID + " ---> PASSENGERS CARRIED ON THE WAY: " + AuxUserMethods.getPassengersCarriedOnTheWayCount(userID));
        }

        public static void testGetUserTripsProposedNumber(int userID)
        {
            System.Console.WriteLine("USER " + userID + " --- > TRIPS PROPOSED: " + AuxUserMethods.getUserTripsProposedNumber(userID));
        }

        public static void testGetUserTripsAsDriverNumber(int userID)
        {
            System.Console.WriteLine("USER " + userID + " --- > TRIPS AS DRIVER: " + AuxUserMethods.getTripsAsDriverCount(userID));
        }

        public static void testGetUserTripsAsPassengerNumber(int userID)
        {
            System.Console.WriteLine("USER " + userID + " --- > TRIPS AS PASSENGER: " + AuxUserMethods.getTripsAsPassengerCount(userID));
        }

        #endregion

        #region distance Tests

        public static void testGetUserTotalKmAsPassenger(int userID)
        {
            System.Console.WriteLine("USER " + userID + " ---> TOTAL KM AS PASSENGER: " + AuxDistanceMethods.getUserTotalKmAsPassenger(userID));
        }

        public static void testGetUserTotalKmAsDriver(int userID)
        {
            System.Console.WriteLine("USER " + userID + " ---> TOTAL KM AS DRIVER: " + AuxDistanceMethods.getUserTotalKmAsDriver(userID));
        }

        public static void testGetStageKm(int stageID)
        {
            System.Console.WriteLine("STAGE " + stageID + " ---> KM: " + AuxDistanceMethods.getStageKm(stageID));
        }

        #endregion

        //public static void testGetTotPasnHistory(DateTime start, DateTime end)
        //{
        //    int[] result = Stats.ReadDailyStatsTableModule.getTotalPassengersHistory(start, end);
        //    foreach (var el in result)
        //    {
        //        System.Console.WriteLine(el);
        //    }
        //}

        public static void testGetTripProperties(int tripID)
        {
            TripProperties tripInfo = AuxTripMethods.getTripProperties(tripID);

            Console.WriteLine("TRIP ID: " + tripInfo.ID);
            Console.WriteLine("TRIP DATE: " + tripInfo.DepartureDate);
            Console.WriteLine("TRIP FROM: " + tripInfo.OriginCity + tripInfo.OriginAddress);
            Console.WriteLine("TRIP TO: " + tripInfo.DestinationCity + tripInfo.DestinationAddress);
            Console.WriteLine("TRIP AVG FREE SEATS: " + tripInfo.AvgFreeSeats + "%");

        }



    }

        

}
